﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SaaS.Core;
using SaaS.Model.Enums;
using XCore.Authorization;
using XCore.Domain.Dto;
using XCore.Extensions;
using XCore.Logger;

namespace Web.System.Controllers
{
    /// <summary>
    /// 文件接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FileController : SystemControllerBase
    {
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <returns></returns>
        [HttpPost, DisableAuditing]
        public ActionResult UploadImage()
        {
            string jsonString = HttpContext.Upload(CoreSetting.UtilServer.Url + UploadType.Default.GetDescription());
            if (jsonString.IsNullOrWhiteSpace()) return Ok("上传失败");
            return Ok(jsonString.ToObject<Result>().Data);
        }
    }
}